You are not logged in Log in Join
You are here: Home » Members » isalsberg » How-to y proyecto para compilar ZMySqlDA » Compiling ZMySQLDA for Zope 2.4 on win32 with MSVC

Log in
Name

Password

 

Compiling ZMySQLDA for Zope 2.4 on win32 with MSVC

Compiling ZMySQLDA for Zope 2.4 on win32 with MSVC

Created by isalsberg

Updated for MySQL-python-0.9.1 and ZMySQLDA 2.0.8

This document explains how-to compile and install the MySQL_python-0.9.1 package used to work with ZMySQLDA 2.0.8. developed by Andy Dustman. This DB Adapter allows the use of transactions.

In order to use the MySQL Database Adapter 2.0.8, You need to compile the MySQL-python-0.9.1 package under WinNT or Win2000.

If You just want to use ZMySQLDA without compiling the MySQL-python extension file, You can get the DLL (and many other binaries) from this page.
You could use either file: _mysql.dll (inside the MS VC project) or _mysql.pyd (from the Useful_binary_collection page). The first one was generated inside the MSVC++ IDE environment, meanwhile the second file was batch created, using the setup.py file. They both work.

I want to thank Hans Olthof, who suggested that would be easier knowing which steps could be omitted if You are only installing.

If You want to install and also compile the MySQL-python package, follow all the steps. By the other hand, if You just want to install ZMySQLDA under Windows environment, skip whole step 3.1. Then go to step 3.2 where says: (If You are only installing, go on from here).

Let's start.

  1. Download the following packages:
  2. You need to:
    • Decompress the "MySQL-python-0.9.1.tar.gz" into temporary area, lets say <Temp>. This will generate the "<Temp>\MySQL-python-0.9.1" directory which has the source file (_mysql.c) to compile the module.
    • Install the python package (optional).
    • Install the MySQL bundle (the best path to do that is c:\mysql)
  3. Now we have two options, choose either one:
    1. Using batch mode (skip this step if just want to install ZMySQLDA):
      • Open a Dos Command Window
      • Go to the directory where the src _mysql.c file is: "<TEMP>\MySQL-python-0.9.1".
      • Edit the file setup.py:
        • Look for the line:
          elif sys.platform == "win32":
        • If You have not installed MySQL using the defaults, then fix the include and library paths, located below the previous line.

      • Then type inside the Dos Window:
      • <Zope_Home2.4>\bin\python setup.py build
      • <Zope_home2.4>\bin\python setup.py install
    2. Using MSVC++ IDE Environment (If You are only installing, just do the last three steps of this section, starting where it says so):
      • Expand my "BuildMySQLDA.zip" file, go the MSVC6\Project directory and double click the "mysql-python.dsw" file to start MSVC++.
      • Open the "Tools->Options" menu. Select the "Directories" Tab and:
        • Select in the drop down list "Show directories for" Include Files and add:
          • path to the MySQL include files (the Include directory beneath You have installed MySQL for Win32).

          Move this directory to the top of the "Directories" window using the arrows to set it as the first include option.

        • Select now Library files and add:
          • path to mysqlclient.lib

          Move this directory to the top of the "Directories" window using the arrows to set it as the first library option.

      • Open the "Project->Settings" menu. Select the "Link" Tab, and at the end of the "Object/library modules" text box add: mysqlclient.lib
      • Build it. This will create the library "_mysql.dll" under the Release directory.
      • (If You are only installing, go on from here)
        Now move the extension file "Release\_mysql.dll" to <Zope_Home2.4>\bin".
      • Go to <Temp>\MySQL-python-0.9.1" directory
      • Copy or move the following to <Zope_Home2.4>\bin:
        • _mysql_exceptions.py
        • CompatMysqldb.py
        • The whole directory MySQLdb

  4. Now install the ZMySQLDA product:
    • Simply untar ZMySQLDA-2.0.8.tar.gz under the Zope's HOME directory.
    • Verify that This generated ZMySQLDA under <Zope_Home2.4>\lib\python\Products.
  5. Restart Zope and add a new "ZMySQL DA Connection".
That's it